!-------------------------------------------------------------LICENSE--------------------------------------------------------------!
!                                                                                                                                  !
!The MAP code is written in Fortran language for magnetohydrodynamics (MHD) calculation with the adaptive mesh refinement (AMR)    !
!and Message Passing Interface (MPI) parallelization.                                                                              !
!                                                                                                                                  !
!Copyright (C) 2012                                                                                                                !
!Ronglin Jiang                                                                                                                     !
!rljiang@ssc.net.cn                                                                                                                !
!585 Guoshoujing Road. Pudong, Shanghai, P.R.C. 201203                                                                             !
!                                                                                                                                  !
!This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License         !
!as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.             !
!                                                                                                                                  !
!This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of    !
!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.                        !
!                                                                                                                                  !
!You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software     !
!Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.                                                   !
!                                                                                                                                  !
!-------------------------------------------------------------LICENSE--------------------------------------------------------------!

!==================================================================================================================================|
subroutine read_parameters
!==================================================================================================================================|

   use parameters
   implicit none

   namelist /parameters_list/                                                                                                      &
      scheme,                                                                                                                      &
      sys,                                                                                                                         &
      ng,                                                                                                                          &
      nx_no_bnd,                                                                                                                   &
      ini_blocks,                                                                                                                  &
      ratio,                                                                                                                       &
      n_levels,                                                                                                                    &
      n_neighs,                                                                                                                    &
      riemann_solver_flag,                                                                                                         &
      output_real8_flag,                                                                                                           &
      cfl,                                                                                                                         &
      t_end,                                                                                                                       &
      dt_output,                                                                                                                   &
      gm,                                                                                                                          &
      pi,                                                                                                                          &
      rangex,                                                                                                                      &
      zero_posx,                                                                                                                   &
      thr_al,                                                                                                                      &
      thr_de,                                                                                                                      &
      thr_ex,                                                                                                                      &
      thr_fl,                                                                                                                      &
      datamap_path

   namelist /parameters_thresholds/                                                                                                &  
      thr_va0

!----------------------------------------------------------------------------------------------------------------------------------|
   open (unit_par, file = trim (directory) // '/' // trim (parameters_filename))
   read (unit_par, nml = parameters_list)
   close (unit_par)

   allocate (thr_va0(sys))
   
   open (unit_par, file = trim (directory) // '/' // trim (parameters_filename))
   read (unit_par, nml = parameters_thresholds)
   close (unit_par)

   n_blocks = ini_blocks
   nx_block = nx_no_bnd + ng * 2
   nx_total = nx_no_bnd * ini_blocks + ng * 2
   eps = epsilon (1.0d0) * 1.0d3
   gmm1 = gm - 1.0d0

!----------------------------------------------------------------------------------------------------------------------------------|
   return
end subroutine read_parameters
